<!DOCTYPE html>
<html lang="zh">

<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<meta http-equiv="Access-Control-Allow-Origin" content="*">
	<title>宇成建筑-找回密码</title>
	<link rel="stylesheet" href="../statics/plugins/layui/css/layui.css" />
	<link rel="stylesheet" href="../statics/css/font.css">
	<link rel="stylesheet" href="../statics/css/login.css">
</head>

<body>
	<header>
		<div class="layui-row">
			<div class="layui-col-xs2 logo">
				<img src="../statics/images/logo.png" alt="" />
				<span></span>
			</div>
			<div class="layui-col-xs10 title">
				<span>君正方华建筑施工劳务企业管理系统</span>
			</div>
		</div>
	</header>
	<main class="forgetPwd-style">
		<div class="main">
			<div class="layui-row title">
				<div class="layui-col-xs12">
					<h2>忘记密码</h2>
				</div>
			</div>
			<div class="input-box">
				<div class='input-width'>
					<i class='iconfontBlod'>&#xe81a;</i>
					<input type="number" placeholder="手机号" id='phone' autocomplete="off" min=0>
                </div>
            </div>
			<div class="input-box login">
				<div class='input-width'>
					<button class="layui-btn layui-btn-normal">找回密码</button>
				</div>
			</div>
		</div>
	</main>
	<footer>
		<p>天津市君正方华科技有限公司 版权信息：xxxxxxxxxxxxx 备案号：津ICP备18000734号</p>
	</footer>
	<script src='../statics/plugins/layui/layui.js'></script>
	<script src='../statics/plugins/jQuery-3.2.1/jquery-3.2.1.min.js'></script>
	<script src='../statics/js/public.js'></script>
	<script>
        layui.use(['layer'], function () {
			var layer = layui.layer;
            var reg = /^1[3456789]\d{9}$/;
            $('body').on('click', '.login button', function() {
                if(reg.test($('#phone').val()) == false) {
                    layer.msg('手机号输入有误,请重新输入!');
                    return;
                } else {
                    $.ajax({
                        url: url + '/auth/forgetPwd',
                        type: "post",
                        data: {
                            phone: $('#phone').val()
                        },
                        dataType: "json",
                        success: function(r) {
                            if(r.code == 100000) {
                                localStorage.setItem('token', r.data.token);
                                window.location.href = 'forgetPwd-newPwd.html';
                            } else {
                                layui.use('layer', function() {
                                    var layer = layui.layer;
                                    layer.open({
                                        type: 1,
                                        title: "验证手机号",
                                        area: ["40%", '30%'],
                                        content: `<p class='one_p'>${r.msg}</p>`,
                                        btn: ['关闭'],
                                        skin: 'my-skin',
                                    })
                                });
                            }
                        }
                    })
                }
            })
        })
		
	</script>
</body>

</html>